#include <gtest/gtest.h>
#include <cstring>

#include "../physical_layer/file_system/InvertedListRecord.h"

using physical::byte;
using physical::InvertedListRecord;
using physical::InvertedListRecordSerializer;
using physical::InvertedList;

class InvertedListRecordTestFixture: public ::testing::Test
{
public:
	InvertedListRecordTestFixture()
    {
        // initialization code here
    }

    void SetUp()
    {
        // code here will execute just before the test ensues
    }

    void TearDown()
    {
        // code here will be called just after the test completes
        // ok to through exceptions from here if need be
    }

    ~InvertedListRecordTestFixture()
    {
        // cleanup any pending stuff, but no exceptions allowed
    }

};

TEST_F ( InvertedListRecordTestFixture, constructor )
{
    InvertedList invertedList = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

    physical::term_id_t termId = 10;

    InvertedListRecord record (termId, invertedList);

    ASSERT_TRUE(record.getID() == termId);

    ASSERT_TRUE(record.getInvertedList() == invertedList);
}

TEST_F ( InvertedListRecordTestFixture, setAndGetInvertedList )
{
    InvertedList invertedList = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

    physical::term_id_t termId = 10;

    InvertedListRecord record (termId);

    record.setInvertedList(invertedList);

    ASSERT_TRUE(record.getID() == termId);

    ASSERT_TRUE(record.getInvertedList() == invertedList);
}

TEST_F ( InvertedListRecordTestFixture, byteContentContructor )
{
    byte invertedList[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

    physical::term_id_t termId = 10;

    InvertedListRecord record (termId, invertedList, 10);

    ASSERT_TRUE(record.getID() == termId);

//    InvertedList test(invertedList, invertedList + 10);
//
//    ASSERT_TRUE( test);
}

